﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace cmsservice.DAL
{
    public class EMStockAnnounceDAL
    {
        delegate DataSet EPioneerDS(string connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters);
        EPioneerDS instance = new EPioneerDS(SqlHelper.ExecuteGetDataSet);

        /// <summary>
        /// 获取个股公告信息
        /// </summary>
        /// <param name="code">股票代码</param>
        /// <returns></returns>
        public DataTable GetEMStockAnnounce(string code)
        {
            DataTable dt = new DataTable();
            try
            {
                string sql = "select top 10 TextID,SecuCode,Title,AnnounceDate,CategoryName2,CategoryName3,CategoryName4,News from vw_sd_stock_msg_announce  where SecuCode=@code order by AnnounceDate desc";
                SqlParameter[] values = { new SqlParameter("@code", code) };
                DataSet ds = instance(DBConn.NewDMSConnstr, CommandType.Text, sql,values);
                if (ds.Tables.Count > 0)
                    dt = ds.Tables[0];
            }
            catch
            {
                dt = null;
            }

            return dt;
        }
    }
}
